/**
 * Copyright (C) 2013 DaiKit.com - daikit-commons module (admin@daikit.com)
 *
 *         Project home : http://code.daikit.com/commons
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.daikit.commons.shared.miscs;

import java.io.Serializable;

import com.daikit.commons.shared.utils.DkObjectUtils;


/**
 * A typed Couple class
 * 
 * @author tcaselli
 * @version $Revision$ Last modifier: $Author$ Last commit: $Date$
 * @param <F>
 *           the type for first attribute
 * @param <S>
 *           the type for second attribute
 */
public class Couple<F, S> implements Serializable
{

	private static final long serialVersionUID = -6271431715091400435L;

	/**
	 * Create a empty Couple
	 */
	public Couple()
	{
		super();
	}

	/**
	 * Create a new couple with the given values
	 * 
	 * @param first
	 *           the first attribute
	 * @param second
	 *           the second attribute
	 */
	public Couple(final F first, final S second)
	{
		this.first = first;
		this.second = second;
	}

	/**
	 * The first attribute
	 */
	public F first;
	/**
	 * The second attribute
	 */
	public S second;

	@Override
	public String toString()
	{
		final StringBuffer sb = new StringBuffer(1000);
		sb.append("(Couple:first=").append(first);
		sb.append(",second=").append(second);
		return sb.append(")").toString();
	}

	@Override
	public boolean equals(final Object obj)
	{
		return obj != null && obj instanceof Couple && DkObjectUtils.equalsWithNull(this.toString(), obj.toString());
	}

	@Override
	public int hashCode()
	{
		return (first == null ? 0 : first.hashCode()) + (second == null ? 0 : second.hashCode());
	}

	/**
	 * Get first attribute
	 * 
	 * @return the first
	 */
	public F getFirst()
	{
		return first;
	}

	/**
	 * Set first attribute
	 * 
	 * @param first
	 *           the first to set
	 */
	public void setFirst(final F first)
	{
		this.first = first;
	}

	/**
	 * Get second attribute
	 * 
	 * @return the second
	 */
	public S getSecond()
	{
		return second;
	}

	/**
	 * Set second attribute
	 * 
	 * @param second
	 *           the second to set
	 */
	public void setSecond(final S second)
	{
		this.second = second;
	}

}
